package com.cet.designpatterns.decorator;

/**
 * @program: algorithm
 * @description: 抽象装饰类
 * @author: 陈恩涛
 * @create: 2021-09-09 22:45
 **/
public abstract class Decorator extends Drink {

    private Drink drink;

    public Decorator(Drink drink) {
        this.drink = drink;
    }

    @Override
    public double cost() {
        // 调味品的价格 super.getPrice()
        // 单品咖啡价格 drink.getPrice()
        return getPrice() + drink.cost();
    }

    @Override
    public String getDes() {
        return super.getDes() +  ":" + super.getPrice() + "&&" + drink.getDes();
    }
}
